<?php
function request($url, $post = array(), $autofollow = true, $debug = false, &$info = '')
{
    $c = curl_init($url);
    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
    if (defined("COOKIEJAR")) {
        curl_setopt($c, CURLOPT_COOKIEJAR, COOKIEJAR);
        curl_setopt($c, CURLOPT_COOKIEFILE, COOKIEJAR);
    }
    curl_setopt($c, CURLOPT_HTTPHEADER, array("User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0;)"));
    if ($autofollow) curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($c, CURLOPT_AUTOREFERER, 1);
    curl_setopt($c, CURLOPT_TIMEOUT, 30);
    curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
    if ($post) {
        if (is_array($post)) {
            $poststr = '';
            foreach ($post as $key => $item) {
                $poststr .= "&" . $key . "=" . urlencode($item);
            }
            $poststr = substr($poststr, 1);
        } else {
            $poststr = $post;
        }
        curl_setopt($c, CURLOPT_POST, 1);
        curl_setopt($c, CURLOPT_POSTFIELDS, $poststr);
    }
    if ($debug) {
        curl_setopt($c, CURLOPT_HEADER, 1);
        curl_setopt($c, CURLINFO_HEADER_OUT, 1);
    }
    $content = trim(curl_exec($c));
    $info = curl_getinfo($c);
    curl_close($c);
    return $content;
}